﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace INTROSE
{
    public partial class Input_Employee_Name : Form
    {
        SqlConnection con = new SqlConnection("Data Source = .\\SQLEXPRESS; Database = Introse; Integrated Security = True");
        private string name, position;
        public int checker;
        public Input_Employee_Name(string name, string position)
        {
            InitializeComponent();
            this.name = name;
            this.position = position;
            con.Open();
            SqlCommand command = new SqlCommand("select uName from users", con);
            SqlDataReader reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    comboUser.Items.Add(reader.GetString(0));
                }
            }
            con.Close();
        }

        private void Input_Employee_Name_Load(object sender, EventArgs e)
        {

        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
            string edit = comboUser.Text;
            this.Close();
            Edit_User edituser = new Edit_User(name, position, edit);
            edituser.Show();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
            if (position == "factory worker")
            {
                MenuProductionStaff menu = new MenuProductionStaff(name, position);
                menu.Show();
            }
            else
            {
                MenuExecutive menu = new MenuExecutive(name, position);
                menu.Show();
            }
        }
    }
}
